package com.dps.omc.utils.telnet;

import com.dps.common.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * Created by DXH on 2016/5/30.
 */
@Service
public class TelnetManager {

    @Autowired
    private TelnetTest telnetTest;

    private TelnetService getOpSystemType(String opSystem){

        if (opSystem.equals(Constants.WIN_OP_SYSTEM)){
            return telnetTest;
        }
        return null;
    }
    public String testConnect(TelnetConnect telnetConnect)throws IOException{

        TelnetService telnetService = getOpSystemType(telnetConnect.getOpSystem());
        if (telnetService == null){
            return "暂不支持该种服务器类型！";
        }
        boolean res = telnetService.testConnect(telnetConnect);
        if (res){
            return "连接成功!";
        }else {
            return "连接失败，请检查参数！";
        }
    }
}
